package testivrs.testivrs;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


public class FacultyReg
{

   public boolean Post(String name,String mobno, String email, String password, String Confirm_password)
   {
       int flag=0;
       String s[]={"1", "2", "3", "4", "5", "6", "7", "8", "9", "&", "\"", "%", "$"};


            for(int j=0; j<s.length; j++)
                if(name.contains(s[j]))
                {
                    System.out.println("Invalid character in name");
                   flag=1;
                }
        //try
        //{
            Long r=Long.parseLong(mobno);

        //}
        /*catch(Exception ex)
        {
            System.out.println("Invalid mobile no");
            flag=1;
        }*/
        if(mobno.length()!=10)
        {
            System.out.println("Invalid mobile no");
            flag=1;
        }

       if((!email.contains("."))||(!email.contains("@")))
                {
           System.out.println("Invalid email id");
           flag=1;
       }



        if(flag==1)
        {
           return false;
        }
        
            Database_access ob = null;

           try{
               ob = new Database_access();

           

           
          if(password.equals(Confirm_password))
           {

             ob.FacultyReg(email, name, password, mobno);

             System.out.println("You have been successfully registered.  Thankyou!");
             return true;
               }
             else
            System.out.println("Passwords do not match");
          	return false;
           } catch (Exception ex) {
             System.out.println("failed");
             return false;


           

        }
            
    }
}

    